//
//  HomeTableViewCell.swift
//  XMGWB
//
//  Created by xiaomage on 15/12/6.
//  Copyright © 2016年 陈经纬. All rights reserved.
//

import UIKit
import SDWebImage

class HomeTableViewCell: UITableViewCell {

    /// 头像
    @IBOutlet weak var iconImageView: UIImageView!
    /// 认证图标
    @IBOutlet weak var verifiedImageView: UIImageView!
    /// 昵称
    @IBOutlet weak var nameLabel: UILabel!
    /// 会员图标
    @IBOutlet weak var vipImageView: UIImageView!
    /// 时间
    @IBOutlet weak var timeLabel: UILabel!
    /// 来源
    @IBOutlet weak var sourceLabel: UILabel!
    /// 正文
    @IBOutlet weak var contentLabel: UILabel!
    
    /// 模型数据
    var status: StatusViewModel?
        {
        didSet{
            // 1.设置头像
           
                iconImageView.sd_setImageWithURL(status?.iconURL)
            
            // 2.设置认证图标
            if let profile = status?.profileImage {
                verifiedImageView.image = profile
            }
            
            // 3.设置昵称
            if let name = status?.statusModel.user!.screen_name{
            nameLabel.text = name
            }
            
            // 4.设置会员图标
            if let mbrank = status?.mbrankImage{
                vipImageView.image = mbrank
                nameLabel.textColor = UIColor.orangeColor()
            }
            
            // 3.设置昵称
            if let name = status?.statusModel.user!.screen_name {
                nameLabel.text = name
            }
            
            
            // 5.设置时间  
            if let creatTime = status?.createdStr {
                timeLabel.text = creatTime
            }
            
            
                // 6.设置来源
                //<a href="http://weibo.com/" rel="nofollow">微博 weibo.com</a>
                //只需要截取"微博 weibo.com"
            if let source = status?.sourceStr{
                sourceLabel.text = source
            }

                // 7.设置正文
                contentLabel.text = status?.statusModel.text
    }
            
            
            
}
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // 1.设置正文最大宽度
        contentLabel.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * 10
    }

    
}
